{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "222ab03c-6c29-42d8-9b92-3f0788cb16a9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "int"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(123)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "2c04d298-0b25-43e1-ac82-9b4efa20aa62",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "str"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type('str')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "30e36c1b-97e4-4268-926f-74777d932f81",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "NoneType"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "d8791f55-06ed-418e-99df-bdd6d0f43421",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "builtin_function_or_method"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(abs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "9e5f44c2-4af4-48ad-87a5-9e961599db9a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type('abc') ==type('123')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "7a370249-ad7d-4fc0-9118-63e9ed18a1a7",
   "metadata": {},
   "outputs": [],
   "source": [
    "def fn():\n",
    "    pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "5691edb9-0aba-4869-8273-3f127af53a34",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import types\n",
    "type(fn) == types.FunctionType"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "1570f631-d91a-41f0-b8fd-20917b501582",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(lambda x: x) == types.LambdaType"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "7fd7c7fc-8fe0-4f82-951a-495377916c31",
   "metadata": {},
   "outputs": [],
   "source": [
    "class Animal(object):\n",
    "    def run(self): \n",
    "        print(\"Animal is running...\")\n",
    "class Dog(Animal): \n",
    "    def run(self): \n",
    "        print(\"Dog is running...\")\n",
    "class Cat(Animal): \n",
    "    def run (slef):\n",
    "        print(\"Cat is running...\")\n",
    "class Husky(Dog): \n",
    "    def run (slef):\n",
    "        print(\"Husky is running...\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "c71a5dc3-3eda-4acc-97c7-6c362a35c62b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = Animal() \n",
    "d = Dog()\n",
    "h = Husky()\n",
    "isinstance(h, Husky)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "12c62c0b-4a07-4f54-b045-06fdaa3f41c7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "isinstance(d, Dog)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "08fac00e-d7a7-46fd-9e3a-0bb23e7fb9c3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "isinstance(d, Animal)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "2f0d76a2-ab1e-43e2-8d55-b71029ba77ea",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['__call__',\n",
       " '__class__',\n",
       " '__delattr__',\n",
       " '__dir__',\n",
       " '__doc__',\n",
       " '__eq__',\n",
       " '__format__',\n",
       " '__ge__',\n",
       " '__getattribute__',\n",
       " '__gt__',\n",
       " '__hash__',\n",
       " '__init__',\n",
       " '__init_subclass__',\n",
       " '__le__',\n",
       " '__lt__',\n",
       " '__module__',\n",
       " '__name__',\n",
       " '__ne__',\n",
       " '__new__',\n",
       " '__qualname__',\n",
       " '__reduce__',\n",
       " '__reduce_ex__',\n",
       " '__repr__',\n",
       " '__self__',\n",
       " '__setattr__',\n",
       " '__sizeof__',\n",
       " '__str__',\n",
       " '__subclasshook__',\n",
       " '__text_signature__']"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dir(abs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "4661cff1-fa33-4336-82b3-e2315a0c5667",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['__add__',\n",
       " '__class__',\n",
       " '__contains__',\n",
       " '__delattr__',\n",
       " '__dir__',\n",
       " '__doc__',\n",
       " '__eq__',\n",
       " '__format__',\n",
       " '__ge__',\n",
       " '__getattribute__',\n",
       " '__getitem__',\n",
       " '__getnewargs__',\n",
       " '__gt__',\n",
       " '__hash__',\n",
       " '__init__',\n",
       " '__init_subclass__',\n",
       " '__iter__',\n",
       " '__le__',\n",
       " '__len__',\n",
       " '__lt__',\n",
       " '__mod__',\n",
       " '__mul__',\n",
       " '__ne__',\n",
       " '__new__',\n",
       " '__reduce__',\n",
       " '__reduce_ex__',\n",
       " '__repr__',\n",
       " '__rmod__',\n",
       " '__rmul__',\n",
       " '__setattr__',\n",
       " '__sizeof__',\n",
       " '__str__',\n",
       " '__subclasshook__',\n",
       " 'capitalize',\n",
       " 'casefold',\n",
       " 'center',\n",
       " 'count',\n",
       " 'encode',\n",
       " 'endswith',\n",
       " 'expandtabs',\n",
       " 'find',\n",
       " 'format',\n",
       " 'format_map',\n",
       " 'index',\n",
       " 'isalnum',\n",
       " 'isalpha',\n",
       " 'isascii',\n",
       " 'isdecimal',\n",
       " 'isdigit',\n",
       " 'isidentifier',\n",
       " 'islower',\n",
       " 'isnumeric',\n",
       " 'isprintable',\n",
       " 'isspace',\n",
       " 'istitle',\n",
       " 'isupper',\n",
       " 'join',\n",
       " 'ljust',\n",
       " 'lower',\n",
       " 'lstrip',\n",
       " 'maketrans',\n",
       " 'partition',\n",
       " 'removeprefix',\n",
       " 'removesuffix',\n",
       " 'replace',\n",
       " 'rfind',\n",
       " 'rindex',\n",
       " 'rjust',\n",
       " 'rpartition',\n",
       " 'rsplit',\n",
       " 'rstrip',\n",
       " 'split',\n",
       " 'splitlines',\n",
       " 'startswith',\n",
       " 'strip',\n",
       " 'swapcase',\n",
       " 'title',\n",
       " 'translate',\n",
       " 'upper',\n",
       " 'zfill']"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dir('abc')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "36fec6ed-72a1-4f69-b0df-6356de8c0c86",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len('abc')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "3d84ee0a-3f34-4de5-9349-1f8e8bd00e1a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'abc'.__len__()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "bb2aebf7-76f7-424d-baa1-cdec85bd25f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "class MyObject(object):\n",
    "\n",
    "    def __init__(self):\n",
    "        self.x = 9\n",
    "\n",
    "    def power(self):\n",
    "        return self.x * self.x\n",
    "obj = MyObject()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "43e90e39-b7f1-428c-932a-9a14b62a9707",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hasattr(obj, 'x')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "23c3c6f9-b1ca-45d0-a46d-cf411fb3f1d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hasattr(obj, 'y')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "1819dc85-ec28-4320-ba00-76a9db7350b3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hasattr(obj, 'z')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "c4296deb-5b9a-4246-9385-93b13abd5ef4",
   "metadata": {},
   "outputs": [],
   "source": [
    "setattr(obj, 'y', 19)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "5576a817-6ca9-4822-9e45-c3e23d73caae",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hasattr(obj, 'y')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "99ae719f-0b40-4631-84b1-400668c7d6f0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "19"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "getattr(obj,'y')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "58f34fbb-5360-4da9-a7bb-cb410dd5add5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "19"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj.y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "d6a137d0-4e96-4b39-91d7-e82e7f058e9a",
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'MyObject' object has no attribute 'z'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[33], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mobj\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mz\u001b[49m\n",
      "\u001b[1;31mAttributeError\u001b[0m: 'MyObject' object has no attribute 'z'"
     ]
    }
   ],
   "source": [
    "obj.z"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "f0519bbe-a1a9-484b-a5ff-35b89ca1b59d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "401"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "getattr(obj, 's', 401)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "a981d490-c16a-465a-8fc6-25b201342af1",
   "metadata": {},
   "outputs": [],
   "source": [
    "fn = getattr(obj,'power')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "2d6a1888-c5c5-44a2-bb2b-de5b67d25fa2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<bound method MyObject.power of <__main__.MyObject object at 0x00000149E24CF310>>"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fn"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0090af1c-ecd9-4ce7-8127-20860ab667a5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.21"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
